// clserver.cpp : Defines the entry point for the console application.
//

// #include "stdafx.h"
#include "winsock.h"
#include "stdio.h"
#pragma comment(lib,"wsock32.lib")

#define SERVER_PORT 0x9
int main(int argc, char* argv[])
{
	SOCKET s;
	sockaddr_in local,remote;
	int len;
	int retval;
	int i;
	char recvbuf[100];
	WSAData wsa;
	int r;
	WSAStartup(0x101,&wsa);

	s = socket(AF_INET,SOCK_DGRAM,0);

	local.sin_family = AF_INET;
	local.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
	local.sin_port = htons(SERVER_PORT);

	bind(s,(sockaddr*)&local,sizeof(local));

	len = sizeof(remote);

	while(1){
	
		remote.sin_family = AF_INET;
		remote.sin_addr.S_un.S_addr = htonl(0x0a000084);
		remote.sin_port = htons(10);

		retval = recvfrom(s,recvbuf,sizeof(recvbuf),0,(sockaddr *)&remote,&len);
		if(retval == -1)
			r = WSAGetLastError();
			printf("retval = %d , recvbuf is %s",retval,recvbuf);

		retval = sendto(s,"ACK",3,0,(sockaddr*)&remote,len);
		if(retval == -1)
			r = WSAGetLastError();

	}
	closesocket(s);

	WSACleanup();
	return 0;
}
